import { createRouter, createWebHashHistory } from "vue-router";

// 固定路由
const constantRoutes = [
  //首页
  {
    path: "",
    redirect: "/main",
  },
  {
    path: "/main",
    component: () => import("@/views/main/index.vue"),
  },
  {
    path: "/child",
    component: () => import("@/views/child/index.vue"),
  },
  {
    path: "/test",
    component: () => import("@/views/test/index.vue"),
  },
];

//路由实例
const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: constantRoutes,
});

//生成路由守卫
router.beforeEach((to, from, next) => {
  next();
});

export default router;
